package com.cras.webcam.http;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/6/24 0024.
 */

public class HttpHeaders {
    private Map<CharSequence,Object> m = new HashMap<CharSequence,Object>();

    public HttpHeaders add(CharSequence name, CharSequence value){
        m.put(name,value);
        return this;
    }

    public HttpHeaders set(CharSequence name, CharSequence value){
        m.put(name,value);
        return this;
    }

    public HttpHeaders set(CharSequence name, List<CharSequence> value){
        m.put(name,value);
        return this;
    }


    public HttpHeaders setLong(CharSequence name, Long value){
        m.put(name,value);
        return this;
    }


    public CharSequence get(CharSequence name){
        return (CharSequence)m.get(name);
    }


    public Long getLong(CharSequence name){
        return (Long)m.get(name);
    }

    public List<CharSequence> getAll(CharSequence name){
        return (List<CharSequence>)m.get(name);
    }
    public void remove(CharSequence name){
        m.remove(name);
    }


    public boolean contains(CharSequence name){
        return m.containsKey(name);
    }

    public boolean contains(CharSequence name, CharSequence value, boolean ignoreCase){
        if (m.containsKey(name)){
            if (ignoreCase && value.equals((String) m.get(name))){
                return true;
            }else if (!ignoreCase && value.equals((String)m.get(name))){
                return true;
            }
        }
        return false;
    }


}
